/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.h
  * @brief          : Header for main.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2022 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32f1xx_hal.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

#include "priority_timer_queue.h"
#include "pid.h"
#include "input.h"
#include "oled.h"
#include "proc.h"
#include "handler.h"
#include "ui.h"

/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

typedef enum
{
    ADC_READ_ERROR = 0, // 加热但ADC没有变化
    ADC_OVER_RANGE,     // ADC超出范围
    END = 0xFFFF
} ERROR_TYPE;


/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */

/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

/* USER CODE BEGIN EFP */

// void set_PWM_CCR(uint16_t ccr)
void T12_Init();

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
#define ADC_Pin GPIO_PIN_1
#define ADC_GPIO_Port GPIOA
#define BLUZZER_Pin GPIO_PIN_3
#define BLUZZER_GPIO_Port GPIOA
#define ENC_A_Pin GPIO_PIN_6
#define ENC_A_GPIO_Port GPIOA
#define ENC_A_EXTI_IRQn EXTI9_5_IRQn
#define ENC_B_Pin GPIO_PIN_7
#define ENC_B_GPIO_Port GPIOA
#define ENC_B_EXTI_IRQn EXTI9_5_IRQn
#define ENC_SW_Pin GPIO_PIN_0
#define ENC_SW_GPIO_Port GPIOB
#define ENC_SW_EXTI_IRQn EXTI0_IRQn
#define PWM_Pin GPIO_PIN_11
#define PWM_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */

/**
 * @brief  pid分段阈值
 */
#define PID_SPLIT_TEMPERATURE_THRESHOLD 15

#define END_WITH_16BIT 0xFFFF

/**
 * @brief adc采集电压对应的温度
 */
#define MAX_VOLT 1.711

/**
 * @brief adc0V对应的温度
 */
#define MIN_VOLT 0.9

// *支持的最大与最小温度
#define MAX_TEMPERATURE 450
#define MIN_TEMPERATURE 260


#define IDENTIFY_TEMPERATURE 290
#define IDENTIFY_ADC 1418

/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */
